home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 August: Tool Chest / Dev.CD Aug 98 TC.toast / Tool Chest / Testing & Debugging / Virtual User / Virtual User Current Release / Examples / Example Scripts / SimpleSample.vu < prev    next >
Encoding:
Text File  |  1998-06-04  |  5.2 KB  |  173 lines  |  [TEXT/MPS ]

  1. #
  2. #    File:        SimpleSample.vu 
  3. #
  4. #    Contains:    A script which creates a folder with 3 sub-folders and does
  5. #                some simple user actions at a slow pace for you to observe.
  6. #                Note that all lines starting with a '#' is a comment 
  7. #                (like this one).                 
  8. #                
  9. #
  10. #    Starting Configuration:    In order for the script to run properly, the target
  11. #                should be running Finder with all windows closed and one disk
  12. #                icon selected. The target Macintosh should have a Printer
  13. #                software installed. If you have access to a printer then use
  14. #                the Chooser to select one.
  15. #
  16. #    After Effects: This script creates a folder called "..VUSimpleSample.." in 
  17. #                the volume selected initially. Please throw it in the trash
  18. #                after you execute this script once.
  19. #
  20. #    Note:        To stop the script execution while its running type Cmd-.
  21. #                ie., Press the Command Key and type '.' (period).  Be sure
  22. #                to open the notebook to see a mini-description of what's going
  23. #                on!
  24. #
  25. #    Written by:    Rick Violet
  26. #
  27. #    Copyright:    © 1990-1992 by Apple Computer, Inc., all rights reserved.
  28. #
  29. #    Change History:
  30. #
  31. #          8/4/92        DGG            Added printed comments.
  32. #         6/19/92        DGG            Cleaned up
  33. #         1/21/90        Rick        Created first draft
  34. #         1/24/90        naga        Edited the script and comments
  35. #
  36. #    To do:
  37. #
  38.  
  39. #Tell VU to slow its movements for Demonstration purposes
  40. println "Now setting environment variables.";
  41. wait(2);
  42. Patience(2);
  43. MouseSpeed(10);
  44.  
  45. # Let user know that the script is starting!
  46. println "### Virtual User!  Simple Sample Now Running!";
  47.  
  48. # Open the root window of the selected volume, by selecting "Open" from the
  49. #    file menu.
  50. println "Selecting ∂"Open∂" from the ∂"File∂" menu.";
  51. wait(2);
  52. select [menuItem t:"Open"];
  53.  
  54. # Unify the window's name into a variable (Volume_Name) for later use.
  55. println "Memorizing the title of the window.";
  56. wait(2);
  57. match[window o:1 t:?volumeName];
  58. println "The window title is ∂"{volumeName}∂".";
  59.  
  60. # Initialize a variable for our folder's name.
  61. ourWindowName := "..VUSimpleSample..";
  62.  
  63. # Create a new folder by selecting 'New', using the key equivalent.
  64. println "Now creating a new folder.";
  65. wait(2);
  66. pressKey k:{ commandKey };
  67. type k:{"n"};
  68. releaseKey k:{ commandKey };
  69.  
  70. # We can rename the folder by simply typing, since it was just created.
  71. println "Now renaming the newly created folder.";
  72. type k:{ ourWindowName };
  73.  
  74. # Open the new folder's window by selecting "Open" from the file menu.
  75. println "Opening the our ∂"{ourWindowName}∂" folder.";
  76. select [ menuitem t:"Open" ];
  77.  
  78. # Check for 'Name already taken' dialog
  79. println "Looking for ∂'Name already taken∂' dialog.";
  80. if match [button t:"Ok" w:1]
  81.     begin
  82.         println "Target not setup to run this script";
  83.         println "Please throw away the '{ ourWindowName }' folder.";
  84.         exit;
  85.     end;
  86.     
  87. # Select and then Close the root window. 
  88. # The variable volumeName contains the window's title.
  89. println "Selecting the ∂"{volumeName}∂" window.";
  90. wait(2);
  91. select [window t:volumeName];
  92. close [window t:volumeName];
  93.  
  94. # Create 3 new folders in this folder using Command-n
  95. println "Creating three new folders in succession.";
  96. wait(2);
  97. pressKey k:{ commandKey };
  98. type k:{"nnn"};
  99. releaseKey k:{ commandKey };
  100.  
  101.  
  102. # Resize the window to be thin and as tall as the screen.
  103. # First find the rectangle of the main screen
  104. match [screen m:true r:?mainScreenRect];
  105.         
  106. # Drag the window to the top-left corner of the screen
  107. println "Moving the window about.";
  108. wait(2);
  109. Drag [ window o:1 ] a:{ mainScreenRect[1],
  110.                         mainScreenRect[2] + 20 }; # bump down 20 for Menubar
  111.  
  112. # Now resize the window.
  113. println "Resizing the window";
  114. wait(2);
  115. Size [ window o:1 ] w:180  h:(mainScreenRect[4] - mainScreenRect[2] - 20 );
  116.  
  117. # View the window by small icon.
  118. println "Changing the view of the window.";
  119. wait(2);
  120. select [menuItem t:"by Small Icon" m:"View"];
  121.  
  122. # Force Finder to clean up the window
  123. println "Now forcing finder to clean up the window.";
  124. wait(2);
  125. pressKey    k:{ optionKey };
  126. select [menuItem t:"Clean up"];
  127. releaseKey    k:{ optionKey };
  128.  
  129. # Zoom the window out 
  130. println "Zooming the window.";
  131. wait(2);
  132. zoom [window o:1];
  133.  
  134. # Do Page setup
  135. println "Now acting with the page setup dialog.";
  136. wait(2);
  137. select [menuItem t:"Page Setup…" m:"File"];
  138.  
  139. # If Page setup dialog comes up.
  140. if (match [radioButton t:"US letter" w:1])
  141. begin
  142.     # Select a radio button, "US letter".
  143.     println "Selecting ∂"US Letter∂" paper size.";
  144.     wait(2);
  145.     select [radioButton t:"US letter" w:1]; 
  146.     
  147.     # Check any check boxes that are currently un-checked in the front window.
  148.     # First, collect the list of all un-checked boxes in the front window.
  149.     AllMarkedCheckBoxes := collect [checkBox s:{0,1} w:1]!;    
  150.     
  151.     # For each one in the list, check the box
  152.     println "Checking boxes.";
  153.     wait(2);
  154.     for each singleBox in AllMarkedCheckBoxes        
  155.         select [checkBox t:singleBox.t r:singleBox.r w:1];    
  156. end;#if Page setup dialog comes back
  157.  
  158. # Dismiss the dialog.
  159. select [button t:'Ok' w:1];                        
  160.  
  161. println "Now performing final organization actions.";
  162. wait(2);
  163.  
  164. # Close the window titled '..VUSimpleSample..'
  165. close [window t:ourWindowName];
  166.  
  167. # Open the root volume window.
  168. select [menuItem t:'Open' m:'File'];
  169.  
  170. # Let user know that the script has finished.
  171. println "### Virtual User! Simple Sample completed!";
  172. println "### Please, don't forget to trash the '{ourWindowName}'∂n",
  173.         "### folder on your target Macintosh!";